using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using UwinEducation.Infrastructure.Persistence;
using UwinEducation.Infrastructure.Repositories;
using UwinEducation.Domain.IRepositories;

namespace UwinEducation.Infrastructure
{
    public static class DependencyInjection
    {
        public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, IConfiguration configuration)
        {
            // 注册通用仓储
            services.AddScoped(typeof(IRepository<,>), typeof(Repository<,>));
            
            // 注册具体仓储
            services.AddScoped<IUserRepository, UserRepository>();
            services.AddScoped<IRoleRepository, RoleRepository>();
            services.AddScoped<IPermissionRepository, PermissionRepository>();

            services.AddScoped<IUserRoleRepository, UserRoleRepository>();
            services.AddScoped<IRolePermissionRepository, RolePermissionRepository>();

            services.AddScoped<IClassroomRepository, ClassroomRepository>();
            services.AddScoped<ICourseRepository, CourseRepository>();
            services.AddScoped<ITermRepository, TermRepository>();
            services.AddScoped<IStudentRepository, StudentRepository>();
            services.AddScoped<ITeacherRepository, TeacherRepository>();

           
            services.AddScoped<ITeacherScheduleRepository, TeacherScheduleRepository>();
            services.AddScoped<ITeacherScheduleDetailsRepository, TeacherScheduleDetailsRepository>();
            services.AddScoped<ITeacherAvailabilityRepository, TeacherAvailabilityRepository>();
            services.AddScoped<ITeacherVacationRepository, TeacherVacationRepository>();
            services.AddScoped<IStudentScheduleRepository, StudentScheduleRepository>();
            services.AddScoped<IStudentPaymentRepository, StudentPaymentRepository>();

            services.AddScoped<IOrderRepository, OrderRepository>();
            services.AddScoped<IOrderDetailRepository, OrderDetailRepository>();
            services.AddScoped<IStudentScheduleDetailsRepository, StudentScheduleDetailsRepository>();
            services.AddScoped<IOrderDiscountRepository, OrderDiscountRepository>();
            services.AddScoped<IOrderPaymentRepository, OrderPaymentRepository>();
            services.AddScoped<IAppointmentRepository, AppointmentRepository>();

            // 注册 SystemConfigRepository
            services.AddScoped<ISystemConfigRepository, SystemConfigRepository>();

            // 注册 DbInitializer
            services.AddScoped<DbInitializer>();

            services.AddScoped<IDescriptionRepository, DescriptionRepository>();


            return services;
        }
    }
} 